package sri.proiect.utils;

import java.sql.*;


public class DatabaseManager {
	
	String url = "jdbc:mysql//localhost:hotels?user=root";
	
	private static DatabaseManager instance;
	
	private Connection connection;
	
	private DatabaseManager(){
		try {
			Class.forName("com.mysql.jdbc.Driver");
			connection = DriverManager.getConnection("jdbc:mysql://127.0.0.1:3306/HOTELS?user=root");
		} 
		catch (Exception e) {
			e.printStackTrace();
		}
	}
	
	public static DatabaseManager getInstance() {
		if (instance == null) {
			instance = new DatabaseManager();
		}
		
		return instance;
	}
	
	public Connection getConnection() {
		return connection;
	}
	

	/*public  void updateHits(int hits, String nume)
	{
		Statement st = null;
		try {
			st = con.createStatement();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		try {
			 st.executeUpdate("update  hotels set hits="+hits+" where nume='"+nume+"'");
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		
		try {
			con.close();
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}*/
	
	} 